package org.apache.commons.lang.text;

public class a implements Cloneable {
    protected char[] a;
    protected int b;
    private String c;

    public a() {
        this(32);
    }

    public a(int i) {
        if (i <= 0) {
            i = 32;
        }
        this.a = new char[i];
    }

    public int a() {
        return this.b;
    }

    public a a(char c) {
        a(a() + 1);
        char[] cArr = this.a;
        int i = this.b;
        this.b = i + 1;
        cArr[i] = c;
        return this;
    }

    public a a(int i) {
        if (i > this.a.length) {
            Object obj = this.a;
            this.a = new char[(i * 2)];
            System.arraycopy(obj, 0, this.a, 0, this.b);
        }
        return this;
    }

    public a a(Object obj) {
        return obj == null ? b() : a(obj.toString());
    }

    public a a(String str) {
        if (str == null) {
            return b();
        }
        int length = str.length();
        if (length <= 0) {
            return this;
        }
        int a = a();
        a(a + length);
        str.getChars(0, length, this.a, a);
        this.b = length + this.b;
        return this;
    }

    public boolean a(a aVar) {
        if (this == aVar) {
            return true;
        }
        if (this.b != aVar.b) {
            return false;
        }
        char[] cArr = this.a;
        char[] cArr2 = aVar.a;
        for (int i = this.b - 1; i >= 0; i--) {
            if (cArr[i] != cArr2[i]) {
                return false;
            }
        }
        return true;
    }

    public a b() {
        return this.c == null ? this : a(this.c);
    }

    public Object clone() throws CloneNotSupportedException {
        a aVar = (a) super.clone();
        aVar.a = new char[this.a.length];
        System.arraycopy(this.a, 0, aVar.a, 0, this.a.length);
        return aVar;
    }

    public boolean equals(Object obj) {
        return obj instanceof a ? a((a) obj) : false;
    }

    public int hashCode() {
        char[] cArr = this.a;
        int i = 0;
        for (int i2 = this.b - 1; i2 >= 0; i2--) {
            i = (i * 31) + cArr[i2];
        }
        return i;
    }

    public String toString() {
        return new String(this.a, 0, this.b);
    }
}
